{% extends "PersonCenter/base.html" %}

{% block title %}修改密码{% endblock %}

{% block file %}
    <link rel="stylesheet" href="{{ url_for('static',filename='css/module.css') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/index.css') }}">
    <link rel="stylesheet" href="{{ url_for('static',filename='css/userdata.css') }}">
    <link href="{{ url_for('static',filename='css/folder/bootstrap.css') }}" rel="stylesheet" type="text/css">
    <script src="{{ url_for('static',filename='css/folder/jquery-1.9.1.min.js') }}"></script>
    <script src="{{ url_for('static',filename='css/folder/bootstrap.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='js/jquery-3.6.0.min.js') }}"></script>
{% endblock %}

{% block body %}
<!--返回-->
<div id="test">
    <span id="sp11"><a style="text-decoration: none" href="{{ url_for("index.index") }}">首页</a></span>&nbsp;>
    <span id="sp22">管理</span>&nbsp;>
    <span id="sp33"><a style="text-decoration: none" href="{{ url_for("person.changePass") }}">修改密码</a></span>
</div>
<!--中间卡片-->
<div class="container">
    <div class="col-md-2">
        <!--左侧导航开始-->
        <div class="panel-group" id="accordion">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <!--主选项：资料修改-->
                    <p class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">资料修改</a>
                    </p>
                </div>
                <div id="collapseTwo" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div><a href="{{ url_for("person.changePass") }}" style="color: black"><b>修改密码</b></a></div>
                        <div><a href="{{ url_for("person.userInfo") }}" style="font-weight: bold">个人资料</a></div>
                        <div><a href="{{ url_for("person.showAdd") }}" style="font-weight: bold">收货管理</a></div>
                    </div>
                </div>
            </div>
        </div>
        <!--左侧导航结束-->
    </div>
    <div class="col-md-10">
        <div class="panel panel-default">
            <ul class="nav nav-tabs">
                <li class="active"><a href="{{ url_for("person.changePass") }}">修改密码</a></li>
                <li><a href="{{ url_for("person.userInfo") }}">个人资料</a></li>
                <li><a href="{{ url_for("person.showAdd") }}">收货管理</a></li>
            </ul>
            <div class="panel-body">
                <!--修改密码表单开始-->
                <form id="form-change-password" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-md-2 control-label">原密码：</label>
                        <div class="col-md-8">
                            <input name="oldPassword" type="text" id="yaunshi" class="form-control" placeholder="请输入原密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">新密码：</label>
                        <div class="col-md-8">
                            <input name="newPassword" type="text" class="form-control" id="old" placeholder="请输入新密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">确认密码：</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" id="new" placeholder="请再次输入新密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <input id="btn-change-password" type="button" class="btn btn-primary" value="修改" />
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--底部-->
<div id="bottom"></div>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;

        //点击修改密码按钮
        $("#btn-change-password").click(function () {
            $.ajax({
                url:"/person/change_Pass",
                type: "post",
                dataType: "json",
                contentType: 'application/json',
                data:JSON.stringify({"oldpass":$("#yaunshi").val(),"newpass":$("#old").val(),"renewpass":$("#new").val()}),
                success:function (json) {
                    console.log(json)
                    if(json.state==200){
                        layer.open({
                            title: '提示'
                            ,content: json.msg,
                            yes: function(layero, index){
                                console.log(layero, index);
                                location.href="{{ url_for("person.changePass") }}";
                            }
                        });
                    }else{
                        layer.open({
                            title: '提示'
                            ,content: json.msg
                        });
                    }
                }
            })
        });
    });
</script>
{% endblock %}